package com.pwt.repository;

import com.pwt.common.ResultPage;
import com.pwt.entity.ProductFeature;
import com.pwt.model.FeatureModel;
import com.pwt.repository.base.DataRepositoryExtension;
import org.apache.commons.lang3.StringUtils;

/**
 * @author dw
 * @version 1.0.0
 * @date 2021/10/28
 */
public class ProductFeatureRepositoryExtensionImpl extends DataRepositoryExtension<ProductFeature,String> implements ProductFeatureRepositoryExtension {


    @Override
    public ResultPage<FeatureModel> queryProductFeaturePage(String name, Integer page, Integer limit) {
        String sql = "SELECT m.METEIL as  partId,m.MEMERKMAL as featureId,(t.TEBEZEICH+'-'+m.MEMERKBEZ) as featureName,m.MEEINHEITTEXT k2142,m.MEUGW k2110,m.MEOGW k2111,m.MENENNMAS K2101  from TEIl t \n" +
                      " left join MERKMAL  m on t.TETEIL=m.METEIL";
        String cSql = "select count(1) from TEIl t left join MERKMAL  m on t.TETEIL=m.METEIL ";
        if(StringUtils.isNotBlank(name)){
            sql +=" where t.TEBEZEICH like N'%"+name+"%'  or m.MEMERKBEZ like N'%"+name+"%'";
            cSql +=" where t.TEBEZEICH like N'%"+name+"%'  or m.MEMERKBEZ like N'%"+name+"%'";
        }
        return super.queryCustomBeanPageBySql(FeatureModel.class,cSql,sql,page-1,limit);
    }
}
